<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.12.4.js"></script>
</head>
<body>
<table border="1">
    <thead>
        <tr>
            <th>用户编号</th>
            <th>用户姓名</th>
            <th>用户密码</th>
            <th>用户地址</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
    <tr th:each="userInfo : ${users}">
        <td th:text="${userInfo.id}"></td>
        <td th:text="${userInfo.username}"></td>
        <td th:text="${userInfo.userpwd}"></td>
        <td th:text="${userInfo.useraddress}"></td>
        <td>
            <a href="http://localhost:8086/selectUser/1">查看</a>
            <button onclick="updateUser()">编辑</button>
            <button onclick="deleteUser()">删除</button>
        </td>
    </tr>
    </tbody>
</table>

</body>
<script>
    function updateUser() {
        var datamsg={userid:1001,username:"tom",userpwd:"123456",useraddress:"青岛"};
        var myjson=JSON.stringify(datamsg);
        console.log(datamsg)
        console.log(myjson)
        $.ajax({
            type:"put",
            url:"/updateUser/1",
            data:myjson,
            dataType:"json",
            contentType:"application/json;charset=UTF-8",
            success:function (response) {
                alert("服务器接收到并响应");

            }
        })


    }

    function deleteUser() {

        $.ajax({
            type:"delete",
            url:"/delteUser/1",
            dataType:"json",
            contentType:"application/json;charset=UTF-8",
            success:function (response) {
                alert("服务器接收到并响应");

            }
        })


    }
</script>
</html>